class Dorfplatz extends Storage {

	private Test test = null;

	public Dorfplatz(int capacity, Test test){
		this(capacity, test, 0);
	}
	
	public Dorfplatz(int capacity, Test test, int initialStock){
		super(capacity, initialStock);
		this.test = test;
	}
	
	// you can not take stuff out of the dorfplatz, so we do nothing
	public synchronized void take(int amount){
	}

	// puts the amount of products into the storage. if there is not enough capacity,
	// the test's stop-method is called
	public synchronized void put(int amount){
		boolean ok = false;
	
		do{
			if(capacity >= (stock+amount)){
				stock += amount;
				ok = true;
				message("i got "+amount);
				notifyAll();
			}
			else {
				test.stop("Dorfplatz is full!");
			}
		} while(ok == false);
	}
	
	public String toString(){
		return "Dorfplatz ("+super.toString()+")";
	}
	
	protected void message(String msg){
		System.out.println("Dorfplatz: "+msg);
	}
}